// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "GameFeatureAction.h"
#include "GameFeaturesSubsystem.h"

#include "GameFeatureAction_WorldActionBase.generated.h"

class FDelegateHandle;
class UGameInstance;
class UObject;
struct FGameFeatureActivatingContext;
struct FGameFeatureDeactivatingContext;
struct FGameFeatureStateChangeContext;
struct FWorldContext;

/**
 * 希望执行特定世界操作的GameFeatureActions的基类
 */
UCLASS(Abstract)
class UGameFeatureAction_WorldActionBase : public UGameFeatureAction
{
	GENERATED_BODY()

public:
	//~ 开始 UGameFeatureAction 接口
	virtual void OnGameFeatureActivating(FGameFeatureActivatingContext& Context) override; // 游戏特性激活时调用
	virtual void OnGameFeatureDeactivating(FGameFeatureDeactivatingContext& Context) override; // 游戏特性停用时调用
	//~ 结束 UGameFeatureAction 接口

private:
	void HandleGameInstanceStart(UGameInstance* GameInstance, FGameFeatureStateChangeContext ChangeContext); // 处理游戏实例开始

	/** 使用特定于操作的逻辑重写 */
	virtual void AddToWorld(const FWorldContext& WorldContext, const FGameFeatureStateChangeContext& ChangeContext) PURE_VIRTUAL(UGameFeatureAction_WorldActionBase::AddToWorld,); // 添加到世界（纯虚函数）

private:
	TMap<FGameFeatureStateChangeContext, FDelegateHandle> GameInstanceStartHandles; // 游戏实例开始句柄映射
};